package com.hongye.furniture.controller;
import com.hongye.common.core.domain.Areas;
import com.hongye.furniture.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: honye-fang
 * @description:
 * @author: Baiyyy
 * @create: 2025-02-14 14:00
 **/
@RestController
@RequestMapping("/area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    /**
     * 查询说有省级区域
     */
    @GetMapping("/province")
    public List<Areas> getProvince() {
        return areaService.getProvince();
    }

    /**
     * 根据省级区域id查询市级区域
     * @return
     */
    @GetMapping("/city/{provinceId}")
    public List<Areas> getCityByProvinceId(@RequestParam Integer provinceId) {
        return areaService.getCityByProvinceId(provinceId);
    }

    /**
     * 根据市级区域id查询县级区域
     */
    @GetMapping("/area/{cityId}")
    public List<Areas> getAreaByCityId(@RequestParam Integer cityId) {
        return areaService.getAreaByCityId(cityId);
    }

}
